# -*- coding: utf-8 -*-
# @Time : 2024/3/13 21:19
# @Author : Hami

import operator
import allure

@allure.step(">>>>>>断言：响应数据断言（assert_exec）")
def assert_exec(type, target_value, assert_value):
    """
    断言的方法
    @param type: 断言类型
    @param target_value: 接口返回值
    @param assert_value: 预期值
    @return:
    """
    if type == "exists":  # 存在 ，这个值不为False
        return target_value != False
    elif type == "contains":  # 包含
        return target_value.__contains__(assert_value)
    elif type == "equals":
        return target_value == assert_value
    else:  # 数学计算
        return getattr(operator, type)(float(target_value), float(assert_value))


# res = assert_exec("gt", "10", "20")
# print(res)
